package com.boot.system.listen;

import cn.hutool.core.bean.BeanUtil;
import com.boot.framework.event.OperateLogEvent;
import com.boot.system.entity.SysOperateLogEntity;
import com.boot.system.service.ISysOperateLogService;
import jakarta.annotation.Resource;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.event.EventListener;

/**
 * @author yangfan
 * @date 2024/3/9
 * @Description
 */
@Configuration
public class OperateLogListen {
    @Resource
    private ISysOperateLogService operateLogService;

    @EventListener()
    public void onApplicationEvent(OperateLogEvent event) {
        operateLogService.save(BeanUtil.fillBeanWithMap(event.getMap(), new SysOperateLogEntity(), false));
    }
}
